# -*- coding:utf-8 -*-
# @Time:2024/4/1921:01
# @Author:miuzg
# @FileName:new test2.py
# @Software:PyCharm
import pymysql

db = pymysql.connect(
    host='127.0.0.1',
    port=3306,
    database='520day6',
    user='root',
    passwd='root',
    charset='utf8'
)

print(db)
# 创建游标
cur = db.cursor()

# 创建sql语句并提交
sql = 'insert into movieinfo(movie_name,director,star) values(%s,%s,%s)'
cur.execute(sql, ['流浪地球2', '郭帆', '吴京'])
db.commit()

# 关闭游标
cur.close()

# 关闭连接
db.close()
